/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tableview;

import data.Designation;
import data.Employees;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Hùng
 */
public class DesignationTableview extends AbstractTableModel {

    List<Designation> lDesig;

    public DesignationTableview() {
        this(new ArrayList<Designation>());
    }

    public DesignationTableview(List<Designation> lDesig) {
        this.lDesig = lDesig;
    }

    public List<Designation> getlDesig() {
        return lDesig;
    }

    public void setlDesig(List<Designation> lDesig) {
        this.lDesig = lDesig;
    }

    @Override
    public int getRowCount() {
        if(lDesig != null ){
             return lDesig.size();
            
        }
        return 0;
    }

    @Override
    public int getColumnCount() {
        return 2;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Object value = null;

        Designation tmpDesign = this.lDesig.get(rowIndex);

        switch (columnIndex) {
            case 0:
                value = tmpDesign.getDesignationid();
                break;
            case 1:
                value = tmpDesign.getDesignation();
                break;
        }
        return value;
    }

    @Override
    public String getColumnName(int column) {
        String value = "";
        switch (column) {
            case 0:
                value = "IdDesign";
                break;
            case 1:
                value = "Designation";
                break;
        }
        return value;
    }
}
